﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:mr="http://mishrareader.codeplex.com/Reader">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/MishraReader;component/Themes/Light/StepControl.xaml" />
        <ResourceDictionary Source="/MishraReader;component/Themes/Light/BusyIndicator.xaml"/>
        <ResourceDictionary Source="/MishraReader;component/Themes/Light/WatermarkPasswordBox.xaml"/>


    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type mr:ComboButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type mr:ComboButton}">
                    <Grid Background="{TemplateBinding Background}">
                        <ToggleButton Template="{DynamicResource ClearComboBoxToggleButton}" Focusable="False" ClickMode="Press" IsTabStop="False" x:Name="PART_Button" Content="{TemplateBinding Header}" IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" />
                        <Popup x:Name="PART_Popup" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" 
                               PlacementTarget="{Binding ElementName=PART_Button}"
                               Placement="Bottom"
                               VerticalOffset="{TemplateBinding VerticalOffset}" 
                               HorizontalOffset="{TemplateBinding HorizontalOffset}"                               
                               AllowsTransparency="True">
                            <Grid x:Name="PART_Content" Margin="10,10,10,10">

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />

                                </Grid.RowDefinitions>

                                <Grid Grid.Row="1">
                                    <Border Background="{DynamicResource MetroBg}" SnapsToDevicePixels="True" BorderBrush="{DynamicResource MetroTextLightLight}" BorderThickness="1">
                                        <Border.Effect>
                                            <DropShadowEffect Color="{DynamicResource MetroLineBrush}" ShadowDepth="1" Direction="0" Opacity="0.3" BlurRadius="5" />
                                        </Border.Effect>
                                    </Border>

                                    <ContentPresenter Margin="10" Content="{TemplateBinding Content}" />
                                </Grid>

                                <Image Grid.Row="0" Stretch="None" Source="/MishraReader;component/Assets/Light/PopupArrow.png" 
                                           HorizontalAlignment="{TemplateBinding ArrowHorizontalAlignment}" 
                                           Margin="{TemplateBinding ArrowMargin}" />
                            </Grid>

                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>




    <Style x:Key="ComboButtonCircleStyle" TargetType="{x:Type mr:ComboButton}">
        <Setter Property="HorizontalOffset" Value="-66" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type mr:ComboButton}">
                    <Grid Background="{TemplateBinding Background}">
                        <ToggleButton Style="{DynamicResource MetroCircleToggleButton}" Focusable="False" ClickMode="Press" IsTabStop="False" x:Name="PART_Button" Content="{TemplateBinding Header}" IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" />
                        <Popup x:Name="PART_Popup" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" 
                               PlacementTarget="{Binding ElementName=PART_Button}"
                               Placement="Bottom"
                               VerticalOffset="{TemplateBinding VerticalOffset}" 
                               HorizontalOffset="{TemplateBinding HorizontalOffset}"                               
                               AllowsTransparency="True">
                            <Grid x:Name="PART_Content" Margin="10,10,10,10">
                                
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />

                                    </Grid.RowDefinitions>

                                    <Grid Grid.Row="1">
                                        <Border Background="{DynamicResource MetroBg}" SnapsToDevicePixels="True" BorderBrush="{DynamicResource MetroTextLightLight}" BorderThickness="1">
                                            <Border.Effect>
                                                <DropShadowEffect Color="{DynamicResource MetroLineBrush}" ShadowDepth="1" Direction="0" Opacity="0.3" BlurRadius="5" />
                                            </Border.Effect>
                                        </Border>

                                        <ContentPresenter Margin="10" Content="{TemplateBinding Content}" />
                                    </Grid>

                                    <Image Grid.Row="0" Stretch="None" Source="/MishraReader;component/Assets/Light/PopupArrow.png" 
                                           HorizontalAlignment="{TemplateBinding ArrowHorizontalAlignment}" 
                                           Margin="{TemplateBinding ArrowMargin}" />                               
                            </Grid>

                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style x:Key="ScrollViewerWithOuterScrollbar" TargetType="{x:Type ScrollViewer}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <ScrollContentPresenter CanContentScroll="{TemplateBinding CanContentScroll}" />

                        <ScrollBar Name="PART_VerticalScrollBar"
                                   HorizontalAlignment="Right"
                                    Grid.Column="1"
                                    Margin="0,0,-10,0"
                                    OverridesDefaultStyle="True"
                                    Value="{TemplateBinding VerticalOffset}"
                                    Maximum="{TemplateBinding ScrollableHeight}"
                                    ViewportSize="{TemplateBinding ViewportHeight}"
                                    Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                    Width="10"/>
                        <ScrollBar Name="PART_HorizontalScrollBar"
                                    Orientation="Horizontal"
                                   VerticalAlignment="Bottom"
                                    Grid.Row="1"
                                   Margin="0,0,0,-10"
                                    OverridesDefaultStyle="True"
                                    Value="{TemplateBinding HorizontalOffset}"
                                    Maximum="{TemplateBinding ScrollableWidth}"
                                    ViewportSize="{TemplateBinding ViewportWidth}"
                                    Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                    Height="10"/>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type mr:FeedItemsListBox}" BasedOn="{StaticResource {x:Type ListBox}}">
        <Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="True" />
        <Setter Property="VirtualizingStackPanel.VirtualizationMode" Value="Recycling" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type mr:FeedItemsListBox}">

                    <ScrollViewer x:Name="PART_ScrollViewer" Style="{StaticResource ScrollViewerWithOuterScrollbar}"  ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                        <ItemsPresenter/>
                    </ScrollViewer>


                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type mr:Dialog}">
        <!--Notice this sets WindowTemplate NOT ControlTemplate.-->
        <Setter Property="WindowTemplate">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type mr:Dialog}">
                    <mr:DialogBoxBase />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style TargetType="{x:Type mr:HtmlViewer}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type mr:HtmlViewer}">

                    <WebBrowser x:Name="PART_browser"
                        mr:WebBrowserUtility.SupressScriptErrors="True"
                        mr:WebBrowserUtility.AutoDetectHtmlContent="True"
                        mr:WebBrowserUtility.BindableSource="{TemplateBinding HtmlString}"
                        mr:WebBrowserUtility.NavigatedCommand="{TemplateBinding NavigatedCommand}"
                        mr:WebBrowserUtility.NavigatingCommand="{TemplateBinding NavigatingCommand}"
                        mr:WebBrowserUtility.OpenLinksExternally="{TemplateBinding OpenLinksExternally}" 
                        mr:WebBrowserUtility.PreventCOMFatalError="True"                              
                        />

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
